;(function() {
  'use strict';

  /**
   * @ngdoc function
   * @name sasApp.controller:logQueryCtrl
   * @description  日志管理模块(logManage)
   * Controller of the sasApp
   */
  angular.module('controllers.userManager.user', [])
    .controller('userSearchCtrl', userSearchCtrl);

  /**
    * [userSearchCtrl 用户管理模块]
   * @param  {type} $scope      [Angular scope]
   * @param  {type} userRequest [Request server]
   * @param  {type} userCRUD    [CRUD service]
   * @param  {type} getIds      [checkbox]
   * @param  {type} userData    [queryParam]
   * @param  {type} $mdDialog   [Angular mdDialog]
   */
  function userSearchCtrl($scope, userRequest, userCRUD, getIds, userData, $mdDialog) {
    $scope.shoumun = 0;
    /**
      * [查询按钮 queryAllChannel] function
     */
    $scope.queryAllChannel = function() {
      $scope.shoumun=$scope.shoumun === 1 ?  0 : 1;
      if ($scope.shoumun === 0) {
        userRequest.userQuery();
      }
    };
    //查询参数
    $scope.queryParam=userData.queryParam;
    //清空用户选择checkbox保存的数组
    userData.ids = [];
    //初始化查询
    $scope.htmlData = userRequest.userQuery();
    //分页查询
    $scope.queryResultPage = userRequest.userQuery;
    //新增用户
    $scope.addU = userCRUD.addUserSave;
    //获取ids
    $scope.getIds = getIds;
    //修改用户
    $scope.modifyU = userCRUD.modifyUser;
    //删除用户
    $scope.delUser = userCRUD.deleteUser;
    //重置密码
    $scope.pwdReset = userCRUD.pwdReset;
    /**
      * [离开页面确保 mdDialog 被销毁] function
     */
    $scope.$on('$destroy', function() {
      $mdDialog.cancel();
    });
  }
  userSearchCtrl.$inject = ['$scope', 'userRequest', 'userCRUD', 'getIds', 'userData', '$mdDialog'];

})();